home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Graphics & Imaging / Ultra Dragging 1.0ß1 / UIconDragging.p < prev    next >
Encoding:
Text File  |  1991-04-02  |  5.6 KB  |  187 lines  |  [TEXT/MPS ]

  1. { UIconDragging.p}
  2. { Copyright © 1990, 1991 by Apple Computer, Inc. All rights reserved.}
  3.  
  4. {    Change List:
  5.  
  6.         ddmmyy
  7.     KJS    040391    First version integrated with TangramUI.
  8.     GAP    010491    Formatting changes and comments.
  9.     GAP    010491    Moved declarations for icon dimensions
  10.                 and insetsto the implementations.
  11.     GAP    010491    Moved gOffscreenManager global to implementation
  12.     GAP    020491    Moved icon height and width back to interface.
  13.     GAP    020491    Moved USES UOffscreenManager to implementation.
  14.     
  15.     End Change List. }
  16.  
  17.  
  18. UNIT UIconDragging;
  19.  
  20. {    This unit provides the capability to drag CICNs from one
  21.     view to another across the desktop.                                }
  22.  
  23.  
  24. INTERFACE
  25.  
  26.  
  27.     USES
  28.     
  29.     {    MacApp }
  30.         UMacApp,
  31.  
  32.     {    Other Building Blocks }
  33.         UOSBitmap,
  34.         UOSImage;
  35.  
  36.  
  37.     CONST
  38.  
  39.         cIconTrackerCmd = 9876;
  40.         kIconWidth = 32;
  41.         kIconHeight = 32;
  42.  
  43.  
  44.     TYPE
  45.  
  46.         IconNumber = INTEGER;
  47.         
  48.         IconPlacementSense = (placeIt, unPlaceIt, rePlaceIt);
  49.  
  50.     {     TTrackingView is an abstract superclass that records its cicns by their
  51.         resource id number -- the most common way.  You will possibly subclass
  52.         from this, or, if your view must be a subclass of some other view class 
  53.         (e.g., TGridView), then you will add the methods of this class to your
  54.         subclass.  IF only Object Pascal had multiple inheritance ...                }
  55.         
  56.         TTrackingView = OBJECT(TView)
  57.  
  58.                 FUNCTION TTrackingView.GetInterViewTracker (anIconNumber: IconNumber;
  59.                                                             offset: Point): TInterViewTracker;
  60.  
  61.                 PROCEDURE TTrackingView.PlaceIcon (anIconNumber: IconNumber;
  62.                                                    aVPoint: VPoint;
  63.                                                    sense: IconPlacementSense);
  64.  
  65.         END; {TTrackingView}
  66.  
  67.  
  68.  
  69.  
  70.     {    TCIconTracker is  and abstract superclass that tracks a color icon,
  71.         manipulating offscreen pixmaps to give the visual effects of full
  72.         color dragging.  Subclasses' TrackMouse method must call INHERITED
  73.         TrackMouse first.                                                        }
  74.  
  75.         TCIconTracker = OBJECT(TCommand)
  76.  
  77.                 fFirstTime: BOOLEAN;        { First time through tracking loop?                                }
  78.                 fLastTime: BOOLEAN;            { Last time through tracking loop?                                }
  79.                 fThisTrackPoint: Point;        { The track point this time through the loop - global coord.    }
  80.                 fLastTrackPoint: Point;        { The track point last time through the loop - global coord.    }
  81.                 fCIcon: CIconHandle;        { The icon we're tracking.                                        }
  82.                 fScreenLocusRect: Rect;        { The area of the screen around the icon.                        }
  83.                 fMaxDepthGrafPort: GrafPtr;    { Parent Grafport for fUnderIcon- maximum bit depth.            }
  84.                 fUnderIcon: TOSImage;        { Offscreen Image of the area under the icon.  Origin = (0, 0)    }
  85.  
  86.                 PROCEDURE TCIconTracker.ICIconTracker (itsCmdNumber: CmdNumber;
  87.                                                        itsDocument: TDocument;
  88.                                                        itsView: TView;
  89.                                                        itsScroller: TScroller;
  90.                                                        anIcon: CIconHandle);
  91.  
  92.                 PROCEDURE TCIconTracker.Free;
  93.                 OVERRIDE;
  94.  
  95.                 PROCEDURE TCIconTracker.Fields (PROCEDURE DoToField (fieldName: Str255;
  96.                                                                      fieldAddr: Ptr;
  97.                                                                      fieldType: INTEGER)); OVERRIDE;
  98.  
  99.             {    Mouse handling }
  100.                 FUNCTION TCIconTracker.TrackMouse (aTrackPhase: TrackPhase;
  101.                                                    VAR anchorPoint, previousPoint, nextPoint: VPoint;
  102.                                                    mouseDidMove: BOOLEAN): TCommand;
  103.                 OVERRIDE;
  104.  
  105.                 PROCEDURE TCIconTracker.CIconTrack (nextPoint: Point);
  106.  
  107.             END; {TCIconTracker}
  108.  
  109.  
  110.     {    TInterViewTracker is an abstract superclass that handles the
  111.         MacApp-isms of moving between views.                                }
  112.  
  113.         TInterViewTracker = OBJECT(TCIconTracker)
  114.  
  115.             fTrackingWindow : TWindow;    { The window we're currently trackign in.  Helps performance.    }
  116.             fTrackingView: TView;        { The view we're currently tracking in.  NIL = Desktop.            }
  117.             fMouseDownOffset: Point;    { Offset of the mouse in relation to the icon.                        }
  118.             fReleasePoint: VPoint;        { The release point of the mouse in fTrackingView's coordinates.    }
  119.  
  120.             PROCEDURE TInterViewTracker.IInterViewTracker (aTrackingView: TView; offset: Point);
  121.  
  122.             PROCEDURE TInterViewTracker.Fields (PROCEDURE DoToField (fieldName: Str255;
  123.                                                                      fieldAddr: Ptr;
  124.                                                                      fieldType: INTEGER)); OVERRIDE;
  125.  
  126.             FUNCTION  TInterViewTracker.GetCIconHandle: CIconHandle;
  127.             
  128.         { Mouse handling }
  129.             FUNCTION TInterViewTracker.TrackMouse (aTrackPhase: TrackPhase;
  130.                                                    VAR anchorPoint, previousPoint, nextPoint: VPoint;
  131.                                                    mouseDidMove: BOOLEAN): TCommand;
  132.             OVERRIDE;
  133.  
  134.         { Actions }
  135.             PROCEDURE TInterViewTracker.DoIt;
  136.             OVERRIDE;
  137.  
  138.         END; {TInterViewTracker}
  139.         
  140.  
  141.     {    TPlaceByNumber is a subclass of TInterViewTracker that records and
  142.         places the tracked icon into a view (in this case a TTrackingView)
  143.         by its resource number.  TPlaceByNumber may be overriden to place
  144.         icons, by resource number, in other types of views.  Similarly
  145.         designed subclasses of TInterViewTracker could place icons in views
  146.         means other than resource number.                                        }
  147.  
  148.         TPlaceByNumber = OBJECT(TInterViewTracker)
  149.  
  150.             fIconNumber : IconNumber;                { The resource id of the cicn being tracked and being placed        }
  151.  
  152.             PROCEDURE TPlaceByNumber.IPlaceByNumber (aTrackingView: TView;
  153.                                                      offset: Point;
  154.                                                      anIconNumber: IconNumber);
  155.  
  156.             PROCEDURE TPlaceByNumber.Fields (PROCEDURE DoToField (fieldName: Str255;
  157.                                                                   fieldAddr: Ptr;
  158.                                                                   fieldType: INTEGER));
  159.             OVERRIDE;
  160.  
  161.             FUNCTION  TPlaceByNumber.GetCIconHandle: CIconHandle;
  162.             OVERRIDE;
  163.             
  164.         { Actions }
  165.             PROCEDURE TPlaceByNumber.DoIt;
  166.             OVERRIDE;
  167.  
  168.             PROCEDURE TPlaceByNumber.UndoIt;
  169.             OVERRIDE;
  170.  
  171.             PROCEDURE TPlaceByNumber.RedoIt;
  172.             OVERRIDE;
  173.  
  174.         END; {TPlaceByNumber}
  175.  
  176.  
  177. { :::::::::::::::::::::::   Unit Initialization  ::::::::::::::::::::::: }
  178.  
  179.  
  180.     PROCEDURE InitUIconDragging;        { This init routine sets up gOffScreenManager.  }
  181.  
  182.  
  183. IMPLEMENTATION
  184.  
  185.     {$I $$Shell(SrcApp)UIconDragging.inc1.p}
  186.  
  187. END. {UNothing}